/* GUARD */
#ifndef __LINEFOLLOW_H__
#define __LINEFOLLOW_H__
#include "lpc_types.h"
#include "SERIALAPI.h"

/* DECLARATIONS */
typedef struct {
  uint8_t FollowSpeed;
  uint8_t P_Factor;     //Perceived displacement from line
  uint8_t P_Quotient;    
  uint8_t D_Factor;     //Rate of correction
  uint8_t D_Quotient; 
} LineFollowCfg;

typedef enum { RAW = 0, CALIBRATED } calib_status;

typedef struct {
  calib_status status;
  uint16_t PC0;
  uint16_t PC1;
  uint16_t PC2;
  uint16_t PC3;
  uint16_t PC4;
} SensorVals;

/* EXTERNS */
extern LineFollowCfg CFG;
extern uint8_t FOLLOWING;
extern SensorVals s;

/* FUNCTION PROTOTYPES */
void LINE_SerialInit(void);
void LINE_ResetCalibration(void);
void LINE_AutoCalibrate(void);
SensorVals* LINE_GetSensors(SensorVals *);

void LINE_StartFollow(LineFollowCfg *);
void LINE_EndFollow(uint8_t);

#endif
